﻿using System.ComponentModel;
using TradeMeSDK;

namespace TradeMo
{
    public class BaseViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyPropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler == null) return;
            TradeMeDispatcher.OnUIThread(() => handler(this, new PropertyChangedEventArgs(propertyName)));
        }

        public void NotifyPropertyChanged(string[] propertyNames)
        {
            var handler = PropertyChanged;
            if (handler == null) return;
            TradeMeDispatcher.OnUIThread(() =>
                {
                    foreach (var propertyName in propertyNames)
                        handler(this, new PropertyChangedEventArgs(propertyName));
                });
        }
    }
}
